package com.zgq.share.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBOpenHelper extends SQLiteOpenHelper {
	
	public static final String DATABASE_NAME = "share.db";
	public static final int DATABASE_VERSION = 1;
	
	public static final String T_WEIBO_AUTH = "weibo_auth";
	
	private static final String CREATE_T_WEIBO_AUTH_SQL = "CREATE TABLE "
		+ T_WEIBO_AUTH + " ("
		+ "[_id] INTEGER  PRIMARY KEY AUTOINCREMENT NULL,"
		+ "[name] VARCHAR  NOT NULL," 
		+ "[token] VARCHAR  NULL," 
		+ "[secret] VARCHAR  NULL,"
		+ "[selected] INTEGER DEFAULT '1' NOT NULL"
		+ ")";

	public DBOpenHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_T_WEIBO_AUTH_SQL);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(String.format("DROP TABLE IF EXISTS [%s]", T_WEIBO_AUTH));
		onCreate(db);
	}

}
